package com.way.capture.adapter.viewholder;

import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;

import com.way.capture.R;
import com.way.capture.activity.DetailsActivity;
import com.way.capture.activity.VideoActivity;
import com.way.capture.data.DataInfo;
import com.way.capture.utils.ItemViewUtil;


public class VideoViewHolder extends ViewHolder {

    public VideoViewHolder(DataInfo albumItem, int position) {
        super(albumItem, position);
    }

    @Override
    public View inflateView(ViewGroup container) {
        ViewGroup v = super.inflateVideoView(container);
        final View view = itemView.findViewById(R.id.image);

        ItemViewUtil.bindTransitionView((ImageView) view, mDataInfo);

        view.setOnClickListener(view1 -> {
            ((DetailsActivity) view1.getContext()).toggleSystemUI();
        });
        final View indicatorView = itemView.findViewById(R.id.video_indicator);
        indicatorView.setOnClickListener(v1 -> {
            VideoActivity.startVideoActivity((DetailsActivity) v1.getContext(), mDataInfo.path, view);
        });
        return v;
    }

    @Override
    public void onSharedElementEnter() {
        final View view = itemView.findViewById(R.id.video_indicator);
        view.animate().alpha(1f);
    }

    @Override
    public void onSharedElementExit(final DetailsActivity.Callback callback) {
        final View view = itemView.findViewById(R.id.video_indicator);
        view.animate().alpha(0f);
        callback.done();
    }
}
